package com.rpframework.module.common.act.api;

import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.google.gson.JsonObject;
import com.rpframework.module.common.utils.DataDictUtils;

@Controller
@RequestMapping("/api/common")
public class DataDictAct {
	
	//社区活动类型 数据字典map
	@RequestMapping(value="/dict",produces = "application/json; charset=utf-8")
	public @ResponseBody String getDataDict(@RequestParam(value="type",required=false) String type,
			@RequestParam(value = "callback",required = false ) String callback){
		JsonObject json = new JsonObject();
		if(StringUtils.isBlank(type)){
			json.addProperty("succ", false);
			json.addProperty("msg", "参数列表必须带有:"+"type");
			return (callback + "(" + json + ")");
		}
		json = DataDictUtils.getDataDictByType(type);
		return (callback + "(" + json + ")");
	}
}
